home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Shareware / Plug-in / Ittec1.7.3.sit / Ittec Installer.pkg / Contents / Resources / postflight < prev    next >
Encoding:
Text File  |  2003-02-23  |  10.2 KB  |  237 lines

  1. #!/bin/bash
  2.  
  3.  
  4. #    quit System Preferences
  5. if { /bin/ps -xco command | /usr/bin/grep -q "^System Prefer"; } then
  6.     /usr/bin/osascript -e 'quit application "System Preferences"'
  7. fi
  8.  
  9.  
  10. #    fix custom icon bits on installed folders
  11. if [ -f /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax/Contents/Resources/Fix ]; then
  12.     /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax/Contents/Resources/Fix -a C /tmp/Ittec_Library/Contextual\ Menu\ Items/Ittec.plugin
  13.     /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax/Contents/Resources/Fix -a C /tmp/Ittec_Library/PreferencePanes/Ittec.prefPane
  14.     /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax/Contents/Resources/Fix -a C /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax
  15.     
  16.     /bin/rm /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax/Contents/Resources/Fix
  17. fi
  18.  
  19. #    insatll to user selected location from /tmp/Ittec_Library
  20. if ! /usr/bin/osascript -e '
  21. tell application "Installer"
  22.     
  23.     set theQuitScript to ¬
  24.         "if { /bin/ps -xco command | /usr/bin/grep -q \"^Finder$\"; } then /usr/bin/osascript -e " & quoted form of "quit application \"Finder\"" & " ; fi"
  25.     
  26.     set theHomeScript to ¬
  27.         "if [ -f /tmp/Ittec_Library/Contextual\\ Menu\\ Items/Ittec.plugin/Contents/MacOS/Ittec ] ; then 
  28. " & "/bin/mkdir -p ~/Library/Contextual\\ Menu\\ Items/ ; /bin/mv -f /tmp/Ittec_Library/Contextual\\ Menu\\ Items/Ittec.plugin ~/Library/Contextual\\ Menu\\ Items/Ittec.plugin ; fi 
  29. " & "if [ -f /tmp/Ittec_Library/PreferencePanes/Ittec.prefPane/Contents/MacOS/Ittec ] ; then 
  30. " & "/bin/mkdir -p ~/Library/PreferencePanes/ ; /bin/mv -f /tmp/Ittec_Library/PreferencePanes/Ittec.prefPane ~/Library/PreferencePanes/Ittec.prefPane ; fi 
  31. " & "if [ -f /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax/Contents/MacOS/Ittec ] ; then 
  32. " & "/bin/mkdir -p ~/Library/ScriptingAdditions/ ; /bin/mv -f /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax ~/Library/ScriptingAdditions/Ittec.osax ; fi 
  33. "
  34.     
  35.     set theRootScript to ¬
  36.         "if [ -f /tmp/Ittec_Library/Contextual\\ Menu\\ Items/Ittec.plugin/Contents/MacOS/Ittec ] ; then 
  37. " & "/bin/mkdir -p /Library/Contextual\\ Menu\\ Items/ ; /bin/mv -f /tmp/Ittec_Library/Contextual\\ Menu\\ Items/Ittec.plugin /Library/Contextual\\ Menu\\ Items/Ittec.plugin ; fi 
  38. " & "if [ -f /tmp/Ittec_Library/PreferencePanes/Ittec.prefPane/Contents/MacOS/Ittec ] ; then 
  39. " & "/bin/mkdir -p /Library/PreferencePanes/ ; /bin/mv -f /tmp/Ittec_Library/PreferencePanes/Ittec.prefPane /Library/PreferencePanes/Ittec.prefPane ; fi 
  40. " & "if [ -f /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax/Contents/MacOS/Ittec ] ; then 
  41. " & "/bin/mkdir -p /Library/ScriptingAdditions/ ; /bin/mv -f /tmp/Ittec_Library/ScriptingAdditions/Ittec.osax /Library/ScriptingAdditions/Ittec.osax ; fi 
  42. "
  43.     
  44.     set theHomeRemove to ¬
  45.         "if [ -f ~/Library/Contextual\\ Menu\\ Items/Ittec.plugin/Contents/MacOS/Ittec ] ; then 
  46. " & "/bin/mkdir -p ~/.Trash/Contextual\\ Menu\\ Items/ ; /bin/mv -f ~/Library/Contextual\\ Menu\\ Items/Ittec.plugin ~/.Trash/Contextual\\ Menu\\ Items/Ittec.plugin ; fi 
  47. " & "if [ -f ~/Library/PreferencePanes/Ittec.prefPane/Contents/MacOS/Ittec ] ; then 
  48. " & "/bin/mkdir -p ~/.Trash/PreferencePanes/ ; /bin/mv -f ~/Library/PreferencePanes/Ittec.prefPane ~/.Trash/PreferencePanes/Ittec.prefPane ; fi 
  49. " & "if [ -f ~/Library/ScriptingAdditions/Ittec.osax/Contents/MacOS/Ittec ] ; then 
  50. " & "/bin/mkdir -p ~/.Trash/ScriptingAdditions/ ; /bin/mv -f ~/Library/ScriptingAdditions/Ittec.osax ~/.Trash/ScriptingAdditions/Ittec.osax ; fi 
  51. " & "if [ -f ~/Library/Application\\ Enhancers/Camel.ape/Contents/MacOS/Camel ] ; then 
  52. " & "/bin/mkdir -p ~/.Trash/Application\\ Enhancers/ ; /bin/mv -f ~/Library/Application\\ Enhancers/Camel.ape ~/.Trash/Application\\ Enhancers/Camel.ape ; fi 
  53. "
  54.     
  55.     set theRootTarget to (POSIX path of (path to "utmp" from local domain)) as text & "Cleanup\\ At\\ Startup/"
  56.     set theRootRemove to ¬
  57.         "if [ -f /Library/Contextual\\ Menu\\ Items/Ittec.plugin/Contents/MacOS/Ittec ] ; then 
  58. " & "/bin/mkdir -p " & theRootTarget & "Contextual\\ Menu\\ Items/ ; /bin/mv -f /Library/Contextual\\ Menu\\ Items/Ittec.plugin " & theRootTarget & "Contextual\\ Menu\\ Items/Ittec.plugin ; fi 
  59. " & "if [ -f /Library/PreferencePanes/Ittec.prefPane/Contents/MacOS/Ittec ] ; then 
  60. " & "/bin/mkdir -p " & theRootTarget & "PreferencePanes/ ; /bin/mv -f /Library/PreferencePanes/Ittec.prefPane " & theRootTarget & "PreferencePanes/Ittec.prefPane ; fi 
  61. " & "if [ -f /Library/ScriptingAdditions/Ittec.osax/Contents/MacOS/Ittec ] ; then 
  62. " & "/bin/mkdir -p " & theRootTarget & "ScriptingAdditions/ ; /bin/mv -f /Library/ScriptingAdditions/Ittec.osax " & theRootTarget & "ScriptingAdditions/Ittec.osax ; fi 
  63. "
  64.     
  65.     set theHome to (path to "dlib" from user domain as text)
  66.     set theRoot to (path to "dlib" from local domain as text)
  67.     set theWord to displayed name of (info for (path to "dlib" from user domain))
  68.     
  69.     set theList to {¬
  70.         word ((number of words in theHome) - 1) of theHome & "/" & theWord, ¬
  71.         first word of theRoot & "/" & theWord, ¬
  72.         last word of displayed name of (info for (path to "trsh" from user domain))}
  73.     
  74.     set hadLogin to false
  75.     set theOption to 0
  76.     set theResult to 1
  77.     
  78.     try
  79.         set theChoice to choose from list theList with prompt "" default items item 1 of theList
  80.         
  81.         if (theChoice as text) is equal to (item 1 of theList as text) then
  82.             set theOption to 1
  83.         end if
  84.         
  85.         if (theChoice as text) is equal to (item 2 of theList as text) then
  86.             set theOption to 2
  87.         end if
  88.         
  89.         if (theChoice as text) is equal to (item 3 of theList as text) then
  90.             set theOption to 3
  91.             set theResult to 0
  92.         end if
  93.     end try
  94.     
  95.     if ( theOption is not 0 ) then
  96.         do shell script "/bin/bash -c " & quoted form of theQuitScript
  97.         do shell script "/bin/bash -c " & quoted form of theHomeRemove
  98.         
  99.         try
  100.             if ((count of (list folder ("/Library/Contextual Menu Items/Ittec.plugin" as POSIX file))) > 0) then
  101.                 set theFlag to 1
  102.                 
  103.                 try
  104.                     repeat while ( theFlag is not 0 )
  105.                         if ( theOption is 2 ) then
  106.                             do shell script "/bin/bash -c " & quoted form of ( theRootRemove & theRootScript ) with administrator privileges
  107.                             
  108.                             set theResult to 0
  109.                             set theOption to 0
  110.                         else
  111.                             do shell script "/bin/bash -c " & quoted form of theRootRemove with administrator privileges
  112.                         end if
  113.                         
  114.                         set theFlag to 0
  115.                     end repeat
  116.                 on error theString number theNumber
  117.                     if ( theNumber < 0 ) then
  118.                         set theResult to 2
  119.                         set theOption to 0
  120.                         set theFlag to 0
  121.                     else
  122.                         beep
  123.                     end if
  124.                 end try
  125.             end if
  126.         end try
  127.         
  128.         tell application "System Events"
  129.             repeat with theItem in login items
  130.                 if path of theItem ends with "Ittec.app" then
  131.                     set hadLogin to true
  132.                 end if
  133.             end repeat
  134.             
  135.             delete (every login item whose path ends with "Ittec.app")
  136.         end tell
  137.     end if
  138.     
  139.     repeat while ( theOption is 2 )
  140.         try
  141.             do shell script "/bin/bash -c " & quoted form of theRootScript with administrator privileges
  142.             
  143.             if ( hadLogin ) then
  144.                 do shell script "/usr/bin/defaults write loginwindow AutoLaunchedApplicationDictionary -array-add " & quoted form of "{ Hide = 0 ; Path = /Library/PreferencePanes/Ittec.prefPane/Contents/Resources/Ittec.app ; }" & " ;"
  145.             end if
  146.             
  147.             set theResult to 0
  148.             set theOption to 0
  149.         on error theString number theNumber
  150.             if ( theNumber < 0 ) then
  151.                 set theOption to 1
  152.             end if
  153.         end try
  154.     end repeat
  155.     
  156.     if ( theOption is 1 ) then
  157.         try
  158.             do shell script "/bin/bash -c " & quoted form of theHomeScript
  159.             
  160.             if ( hadLogin ) then
  161.                 do shell script "/usr/bin/defaults write loginwindow AutoLaunchedApplicationDictionary -array-add " & quoted form of (("{ Hide = 0 ; Path = " & (POSIX path of (path to "dtop" from user domain)) as text) & "Library/PreferencePanes/Ittec.prefPane/Contents/Resources/Ittec.app ; }") & " ;"
  162.             end if
  163.             
  164.             set theResult to 0
  165.         end try
  166.     end if
  167.     
  168.     do shell script "/bin/rm -rf /tmp/Ittec_Library/"
  169.     
  170.     if ( theResult is not 0 ) then
  171.         activate application "Finder"
  172.         activate application "Installer"
  173.         
  174.         error number theResult
  175.     end if
  176. end tell
  177. '
  178. then
  179. exit 1
  180. fi
  181.  
  182.  
  183. #    remove temporary files
  184. /bin/rm -rf /tmp/Ittec_Library/
  185.  
  186. #    check to see if preference file exists
  187. if [ -f ~/Library/Preferences/com.balance.ittec.plist ]; then
  188.  
  189. /usr/bin/defaults write com.balance.ittec ListDesktopInMenuBar -boolean true
  190.  
  191. /usr/bin/osascript -e '
  192. tell application "Finder"
  193.     Get Ittec Windows
  194. end tell
  195. '
  196.  
  197. else
  198.  
  199. #    create default preference file
  200. /usr/bin/defaults write com.balance.ittec CreateLoginItem -boolean true
  201. /usr/bin/defaults write com.balance.ittec ControlFreeContextDelay -float 0.8
  202. /usr/bin/defaults write com.balance.ittec DesktopSystemFolderArray -array -integer -32763 cusr
  203. /usr/bin/defaults write com.balance.ittec KeyCopyToClipboard -array -integer 8 c
  204. /usr/bin/defaults write com.balance.ittec KeyOpen -array -integer 31 o
  205. /usr/bin/defaults write com.balance.ittec KeyPrint -array -integer 35 p
  206. /usr/bin/defaults write com.balance.ittec KeySelect -array "+" -integer 24
  207. /usr/bin/defaults write com.balance.ittec KeyUnselect -array "-" -integer 27
  208. /usr/bin/defaults write com.balance.ittec KeyShowInFinder -array -integer 1 s
  209. /usr/bin/defaults write com.balance.ittec ListContentsInPathMenu -boolean true
  210. /usr/bin/defaults write com.balance.ittec ListDesktopInMenuBar -boolean true
  211. /usr/bin/defaults write com.balance.ittec ListFoldersInDesktop -boolean true
  212. /usr/bin/defaults write com.balance.ittec ListPathMenuAsContext -boolean true
  213. /usr/bin/defaults write com.balance.ittec ListProcessInDesktop -boolean true
  214. /usr/bin/defaults write com.balance.ittec ListVolumesInDesktop -boolean true
  215. /usr/bin/defaults write com.balance.ittec ListWindowsInDesktop -boolean true
  216. /usr/bin/defaults write com.balance.ittec ShowInformationWindow -boolean true
  217. /usr/bin/defaults write com.balance.ittec ShowMoreInformation -boolean true
  218. /usr/bin/defaults write com.balance.ittec UseCustomIcons -integer 3
  219. /usr/bin/defaults write com.balance.ittec UseCustomSettings -boolean true
  220. /usr/bin/defaults write com.balance.ittec UseItalicForAliases -boolean true
  221.  
  222. #    launch Finder and load Ittec.osax
  223. /usr/bin/osascript -e '
  224. tell application "Finder"
  225.     Get Ittec Windows
  226. end tell
  227. '
  228.  
  229. #    open Ittec preferences
  230. if [ -f ~/Library/PreferencePanes/Ittec.prefPane/Contents/MacOS/Ittec ]; then
  231. /usr/bin/open -a "/Applications/System Preferences.app" ~/Library/PreferencePanes/Ittec.prefPane
  232. elif [ -f /Library/PreferencePanes/Ittec.prefPane/Contents/MacOS/Ittec ]; then
  233. /usr/bin/open -a "/Applications/System Preferences.app" /Library/PreferencePanes/Ittec.prefPane
  234. fi
  235.  
  236. fi
  237.